package com.gaoxiang.demo;

import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.result.UpdateResult;
import org.bson.Document;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * TODO
 *
 * @author gaoxiang
 * @date 2020/9/916:35
 */
public class MongodbTest {
    public  static  void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        String str = "abcdefghijklmn";
        String res = str.substring(3);
        Long l = Long.parseUnsignedLong(res,16);
        str=str+"1234";
        StringBuffer sbf = new StringBuffer();
        sbf.toString();
        System.out.println(res);
//            //连接MongoDB服务器，端口号为27017
//            MongoClient mongoClient = new MongoClient("localhost", 27017);
//            //连接数据库
//            MongoDatabase mDatabase = mongoClient.getDatabase("abc");
//            //获取集合
//            MongoCollection collection = mDatabase.getCollection("list");
//            //插入
//            collection.insertOne(new Document("name","test123").append("sex", "男"));
//            System.out.println("插入成功");
//            //批量插入
//            List<Document> documents=new ArrayList<>();
//            documents.add(new Document("name","text111").append("sex", "女"));
//            documents.add(new Document("name","chaoba4565").append("sex", "男"));
//            collection.insertMany(documents);
//            System.out.println("批量插入成功");
//            //更新一个
//            collection.updateOne(Filters.eq("name", "test123"), new Document("$set",new Document("name","暮雪超霸")));
//            System.out.println("更新成功");
//            //查询所有一
//            FindIterable<Document> result=collection.find();
//            for (Document document : result) {
//                System.out.println(document);
//            }
    }
}
